
#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        let result = 2 + 2;
        assert_eq!(result, 4);
    }


    #[test]
    fn youdao_response() -> Result<(), Box<serde_json::Error>> {
        let s = r#"
        {
            "note": "参见有道英中词典 https://ai.youdao.com/DOCSIRMA/html/%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E7%BF%BB%E8%AF%91/API%E6%96%87%E6%A1%A3/%E6%9C%89%E9%81%93%E8%AF%8D%E5%85%B8%E6%9C%8D%E5%8A%A1/%E6%9C%89%E9%81%93%E8%AF%8D%E5%85%B8%E6%9C%8D%E5%8A%A1-API%E6%96%87%E6%A1%A3.html",
            "errorCode": "0",
            "requestId": "2a58e3a7-7fc7-447f-aa9c-c446cf7077c4",
            "msg": "success",
            "result": [{
                "ec": {
                    "returnPhrase": ["good"],
                    "web": [{
                        "phrase": "good",
                        "meanings": ["好的", "善", "良好", "商品"]
                    }, {
                        "phrase": "Good Friday",
                        "meanings": ["耶稣受难节", "耶稣受难日", "受难节"]
                    }, {
                        "phrase": "Good Will Hunting",
                        "meanings": ["心灵捕手", "骄阳似我", "心魄捕手"]
                    }],
                    "synonyms": [{
                        "pos": "adj.",
                        "words": ["fine", "Ok", "great", "religious", "bright"],
                        "trans": "好的；优良的；愉快的；虔诚的"
                    }, {
                        "pos": "n.",
                        "words": ["benefit", "plus", "mercy"],
                        "trans": "好处；善行；慷慨的行为"
                    }, {
                        "pos": "adv.",
                        "words": ["okey"],
                        "trans": "好"
                    }],
                    "dict": "yddict://m.youdao.com/dict?le=en&q=good",
                    "basic": {
                        "usPhonetic": "ɡʊd",
                        "usSpeech": "http://openapi.youdao.com/ttsapi?q=good&langType=en&sign=49F6290EA9640CA7DCA265281D86510E&salt=1612690100745&voice=6&appKey=zhudytest123",
                        "phonetic": "ɡʊd",
                        "ukSpeech": "http://openapi.youdao.com/ttsapi?q=good&langType=en&sign=49F6290EA9640CA7DCA265281D86510E&salt=1612690100745&voice=5&appKey=zhudytest123",
                        "examType": ["初中", "高中", "CET4", "CET6", "考研"],
                        "explains": [{
                            "pos": "adj.",
                            "text": null,
                            "trans": "好的；优良的；愉快的；虔诚的"
                        }, {
                            "pos": "n.",
                            "text": null,
                            "trans": "好处；善行；慷慨的行为"
                        }, {
                            "pos": "adv.",
                            "text": null,
                            "trans": "好"
                        }, {
                            "pos": "n.",
                            "text": null,
                            "trans": "(Good)人名；(英)古德；(瑞典)戈德"
                        }],
                        "ukPhonetic": "ɡʊd",
                        "wordFormats": [{
                            "name": "比较级",
                            "value": "better"
                        }, {
                            "name": "最高级",
                            "value": "best"
                        }, {
                            "name": "复数",
                            "value": "goods"
                        }]
                    },
                    "phrases": [{
                        "phrase": "good at",
                        "meanings": ["善于"]
                    }, {
                        "phrase": "good and",
                        "meanings": ["完全，非常"]
                    }, {
                        "phrase": "good for",
                        "meanings": ["有效的；会产生；有支付…能力的"]
                    }, {
                        "phrase": "good quality",
                        "meanings": ["良好品质，高品质；好质量"]
                    }, {
                        "phrase": "no good",
                        "meanings": ["很糟，没有用"]
                    }, {
                        "phrase": "make good",
                        "meanings": ["成功；赔偿；补偿"]
                    }, {
                        "phrase": "as good as",
                        "meanings": ["和…几乎一样，实际上等于…"]
                    }, {
                        "phrase": "do good",
                        "meanings": ["对……有好处；有用处"]
                    }, {
                        "phrase": "feel good",
                        "meanings": ["感觉舒服，感觉良好"]
                    }, {
                        "phrase": "good reputation",
                        "meanings": ["良好声誉"]
                    }, {
                        "phrase": "good news",
                        "meanings": ["好消息；福音；喜讯；福音"]
                    }, {
                        "phrase": "good job",
                        "meanings": ["好运；幸运的事情；干的不错"]
                    }, {
                        "phrase": "good idea",
                        "meanings": ["好主意，好想法；妙计"]
                    }, {
                        "phrase": "good morning",
                        "meanings": ["int. 早安，早上好"]
                    }, {
                        "phrase": "good performance",
                        "meanings": ["良好的性能；良好绩效"]
                    }, {
                        "phrase": "good friend",
                        "meanings": ["好朋友，挚友"]
                    }, {
                        "phrase": "good health",
                        "meanings": ["身体健康"]
                    }, {
                        "phrase": "good time",
                        "meanings": ["好时机；繁荣时期"]
                    }, {
                        "phrase": "good service",
                        "meanings": ["好的服务；合法发球"]
                    }, {
                        "phrase": "for good",
                        "meanings": ["永久地；一劳永逸地"]
                    }],
                    "lang": "en",
                    "sentenceSample": [{
                        "sentence": "His diction wasn't very good.",
                        "sentenceBold": "His diction wasn't very <b>good</b>.",
                        "translation": "他的发音不是很好。"
                    }, {
                        "sentence": "Cats have good night vision.",
                        "sentenceBold": "Cats have <b>good</b> night vision.",
                        "translation": "猫在夜间视力好。"
                    }, {
                        "sentence": "The play had good reviews.",
                        "sentenceBold": "The play had <b>good</b> reviews.",
                        "translation": "这部戏受到好评。"
                    }, {
                        "sentence": "We remained good friends.",
                        "sentenceBold": "We remained <b>good</b> friends.",
                        "translation": "我们一直是好朋友。"
                    }, {
                        "sentence": "She has very good sight.",
                        "sentenceBold": "She has very <b>good</b> sight.",
                        "translation": "她的视力很好。"
                    }],
                    "isWord": true,
                    "webDict": "http://mobile.youdao.com/dict?le=en&q=good"
                }
            }]
        }
  
  "#;
  
        // Parse the string of data into serde_json::Value.
        let v: serde_json::Value = serde_json::from_str(s)?;

        assert_eq!(v["errorCode"], "0");
        assert_eq!(v["msg"], "success");
        assert_eq!(v["result"][0]["ec"]["lang"], "en");
        assert_eq!(v["result"][0]["ec"]["sentenceSample"].as_array().unwrap().len(),5);

        Ok(())
    }
}
